package my_project.util
object IPUtils {
  def main(args: Array[String]): Unit = {
    println(ip2Long("182.91.190.221"))
  }
  /**
   *将字符串转化成十进制
   * @param ip
   */
  def ip2Long(ip:String): Long ={
    val fragments = ip.split("[.]")
    var ipNum = 0L
    for (i <- 0 until fragments.length){
      ipNum =  fragments(i).toLong | ipNum << 8L
    }
    ipNum
}
}
